﻿using System;
using System.Data;
using System.Configuration;
using System.Web;

using System.Globalization;
using System.Text;

namespace ZLDC.Common
{
    public class C_SeperateWord
    {
        public C_SeperateWord()
        {
        }
        /*
         * 编写人:mico
         * 日期:  2009-04-01
         * 功能: 按大小写拆分英文字符
         * s:要转换的字串
        */
        public static string SepWord(String s)
        {
            TextInfo Tinfo = CultureInfo.InvariantCulture.TextInfo;
            return Tinfo.ToTitleCase(s);
        }

        public static string StringToAscii(String s)
        {
            byte[] sby = System.Text.Encoding.UTF8.GetBytes(s);
            string str = "";
            for (int i = 0; i < sby.Length; i++)
            {
                str += sby[i].ToString();
            }
            return str;
        }

        public static string PPCase(String s)
        {
            string Str = s.ToLower();
            int i;
            i = int.Parse(StringToAscii("a"));
            while (i <= int.Parse(StringToAscii("z")))
            {
                Str = Str.Replace(" " + (char)i, " " + (char)(i - 32));
                i = i + 1;
            }
            if (int.Parse(StringToAscii(Str.Substring(0, 1))) >= int.Parse(StringToAscii("a")) && int.Parse(StringToAscii(Str.Substring(0, 1))) <= int.Parse(StringToAscii("z")))
            {
                Str = (char)(int.Parse(StringToAscii(Str.Substring(0, 1))) - 32) + Str.Substring(1, Str.Length);
            }
            return Str;
        }

    }
}
